Page({
    data: {
        navLeftItems: [
            {name: '日用美物',id: '0'},
            {name: '夏季专区',id: '1'},
            {name: '精选新品',id: '2'},
            {name: '优选榜单',id: '3'},
            {name: '服装',id: '4'},
            {name: '餐厨',id: '5'},
            {name: '配件',id: '6'},
            {name: '居家',id: '7'},
            {name: '洗护',id: '8'},
            {name: '婴童',id: '9'},
            {name: '美食',id: '10'},
            {name: '美妆',id: '11'},
            {name: '图书',id: '12'},
            {name: '家电',id: '13'}
        ],
        curNav: 0,
        curIndex: 0
    }, 
    leftMethod(e) {
        let that = this;
        let index = e.currentTarget.dataset.index;
        that.setData({
            curNav: index,
            curIndex: index
        })
    },
    showImg(){
        let group = this.data.group
        let height = this.data.height
    
        wx.createSelectorQuery().selectAll('.classify-content').boundingClientRect((ret) => {
         console.log(ret);
         ret.forEach((item, index) => { 
           if (item.top <= height) { 判断是否在显示范围内
             group[index].show = true // 根据下标改变状态
           }
         })
         this.setData({
           group
         })
        }).exec()
    },
    onPageScroll(res){ // 滚动事件 this.showImg()
        console.log(res);
        this.showImg();
    }
})